﻿/****************************** Module Header ******************************\
 * Module Name:  ExMethodForControl.cs
 * Module Version:  1.0.0 (2012-8-25)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to extension winformcontrol instance's method.  It supplies 
 * public static extension methods to load data or get othor control.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace UCF.Core.Forms
{
    public static class ExMethodForControl
    {
        /// <summary>
        /// 控件集转换成控件列表
        /// </summary>
        /// <param name="cc"></param>
        /// <param name="filters">要过滤的控件类型</param>
        /// <returns></returns>
        public static IList<Control> ToList(this Control.ControlCollection cc, params Type[] filters)
        {
            IList<Control> list = new List<Control>();
            foreach (Control c in cc)
            {
                if (filters != null && filters.Contains(c.GetType())) continue;
                list.Add(c);
            }
            return list;
        }
    }
}
